package org.huntaway.kindergarten.service.common;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.huntaway.kindergarten.manager.ClassInfoMng;
import org.huntaway.kindergarten.manager.GenearchMng;
import org.huntaway.kindergarten.manager.StudentMng;
import org.huntaway.kindergarten.manager.TeacherMng;
import org.huntaway.kindergarten.po.Student;
import org.huntaway.kindergarten.service.KindProcessor;
import org.huntaway.kindergarten.util.GlobalCon;

public class StudentSeleService  extends KindProcessor<Student> {
	public StudentSeleService() {
		super();
		baseMng = (StudentMng) sm.getMng(GlobalCon.STUDENT);
	}
	@Override
	public Student getObj() {
		return new Student();
	}

	public ActionForward query(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		item = (Student) setValue(request, getObj());
		ActionForward serBean = super.query(mapping, form, request, response);
		setPageValue(request);
		return serBean;
	}
	public ActionForward operate(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		item = (Student) setValue(request, getObj());
		ActionForward serBean = super.query(mapping, form, request, response);
		setPageValue(request);
		return serBean;
	}
	public ActionForward list(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		item = (Student) setValue(request, getObj());
		ActionForward serBean = super.list(mapping, form, request, response);
		setPageValue(request);
		return serBean;
	}
	private void setPageValue(HttpServletRequest request) {
		request.setAttribute("classLst",
				((ClassInfoMng) sm.getMng(GlobalCon.CLASS_INFO)).getClassInfo());
		request.setAttribute("genearchLst",
				((GenearchMng) sm.getMng(GlobalCon.GENEARCH)).getGenearch());
		request.setAttribute("teacherLst",
				((TeacherMng) sm.getMng(GlobalCon.TEACHER)).getTeacher());
	}
}
